import { ObjCreate } from "../../common/ObjCreate";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../resource/ImagesConst";
import { GLabel } from "../../../../../com/mui/controls/GLabel";
import { _colorConfig } from "../../../../../this/_colorConfig";
type int = number;
//class ExAttributeItemLabel
    
    export  class ExAttributeItemLabel /* flash.display.Sprite */
    {
        constructor()
        {
            
            this._colorConfig = ["#FF00FF", "#ffff00", "#00ff00"];
            this.createChildren();
            return;
        }

        /* internal  */createChildren(): void
        {
            this._nameLabel = ObjCreate.createLabel("", 0, 0, 100, 20, flash.text.TextFormatAlign.LEFT, this, true, 16702014);
            this._valueLabel = ObjCreate.createLabel("", 40, 0, 100, 20, flash.text.TextFormatAlign.LEFT, this, true, 16702014);
            var loc1=new Object /* flash.display.Sprite */();
            this.addChild(loc1);
            this._lockBm = new Object /* flash.display.Bitmap */();
            this._lockBm.x = 115;
            loc1.addChild(this._lockBm);
            loc1.buttonMode = true;
            loc1.addEventListener(flash.events.MouseEvent.CLICK, this.onLockClick);
            this.useLock = false;
            return;
        }

        /* internal  */onLockClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (this.isCanChangeLock) 
            {
                this.useLock = !this.useLock;
                this.updateLabels();
                this.dispatchEvent(new Object /* flash.events.Event */(this.LockClick, true, false));
            }
            return;
        }

        public updateData(arg1: string, arg2: string, arg3: Boolean, arg4: int, arg5: Boolean): void
        {
            this._label = arg1;
            this._value = arg2;
            this._isMax = arg5;
            this.pos = arg4;
            this.useLock = arg3;
            this.updateLabels();
            return;
        }

        /* internal  */updateLabels(): void
        {
            var loc1=this.useLock ? this._colorConfig[2] : _colorConfig[1];
            if (!this._isMax) 
            {
                loc1 = this._colorConfig[0];
            }
            if (!this.showLock) 
            {
                if (this.useLock) 
                {
                    loc1 = "#9f9f9f";
                }
                else 
                {
                    loc1 = this._isMax ? this._colorConfig[1] : _colorConfig[0];
                }
            }
            this._nameLabel.htmlText = HTMLUtil.addColor(this._label, loc1);
            this._valueLabel.htmlText = HTMLUtil.addColor(this._value, loc1);
            return;
        }

        public set useLock(arg1: Boolean)
        {
            this._useLock = arg1;
            if (this._label == "" && this._value == "") 
            {
                this._lockBm.bitmapData = null;
                return;
            }
            if (this.showLock) 
            {
                if (this._useLock) 
                {
                    this._lockBm.bitmapData = GlobalClass.getBitmapData(ImagesConst.RecastAttribute_Lock);
                }
                else if (this.isCanChangeLock) 
                {
                    this._lockBm.bitmapData = GlobalClass.getBitmapData(ImagesConst.RecastAttribute_UnLock);
                }
                else 
                {
                    this._lockBm.bitmapData = null;
                }
            }
            else 
            {
                this._lockBm.bitmapData = null;
            }
            this.updateLabels();
            return;
        }

        public get useLock(): Boolean
        {
            return this._useLock;
        }

        public clear(): void
        {
            this._label = "";
            this._value = "";
            this._nameLabel.htmlText = "";
            this._valueLabel.htmlText = "";
            this._useLock = false;
            this._lockBm.bitmapData = null;
            return;
        }

        public /* const */LockClick: string="LockClick";

        /* internal */ /* var */_useLock: Boolean;

        public /* var */pos: int;

        public /* var */showLock: Boolean=true;

        public /* var */isCanChangeLock: Boolean=true;

        /* internal */ /* var */_nameLabel: GLabel;

        /* internal */ /* var */_valueLabel: GLabel;

        /* internal */ /* var */_lockBm: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_curColor: string;

        /* internal */ /* var */_isMax: Boolean=true;

        /* internal */ /* var */_colorConfig: Array<any>;

        /* internal */ /* var */_label: string="";

        /* internal */ /* var */_value: string="";
    }
